using UnityEngine;
using UnityEngine.UI;

namespace UFrame
{

    /// <summary>
    /// Tooggle简单切换
    /// </summary>
    [RequireComponent(typeof(Toggle))]
    public class UIToggleChange : MonoBehaviour
    {
        public GameObject isOn;
        public GameObject isNotOn;
        private void Awake()
        {
            var t = GetComponent<Toggle>();
            isOn.SetActive(t.isOn);
            isNotOn.SetActive(!t.isOn);

            UIEventListener.ToggleListener(gameObject, (go, r) =>
            {
                isOn.SetActive(r);
                isNotOn.SetActive(!r);
            });
        }
    }
}